<!doctype html>
<html>
	<head>
		<title> *** </title>
	</head>

	<body>
  
	</body>
</html>
<script src="http://cdn.sockjs.org/sockjs-0.3.4.min.js"></script>
<script type="text/javascript">
var sock = new SockJS('/ws/socketio/');
sock.onopen = function(){
	console.log('open');
};
sock.onclose = function(){
	console.log('close');
};

sock.onmessage = function(e){
	console.log(e.data);

	if(!e.data)
		return;

	var obj = JSON.parse(e.data);
	if(obj && 'order-refresh' == obj.action){
		console.log('order new...');
	}
};

function send(message){
	if(sock.readyState === SockJS.OPEN){
		console.log('sending message')
		sock.send(JSON.stringify(message));
	}else{
		console.log('The socket is not open.');
	}
}

window.onbeforeunload = function(){
	sock.close();
};

setTimeout(function(){
	// TODO
	var testOpenid = 'oQMltt6f8dgCfkst6T5f-T7BEawk';
	send({action: 'mapping-openid', openid: testOpenid});
}, 1000 * 5);
</script>